using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class DarkworldMenu_BarPartyMember : MonoBehaviour
{
	public ActivePartyMember CurrentMember;

	[SerializeField]
	private Image Icon;

	[SerializeField]
	private Image Name;

	[SerializeField]
	private TextMeshProUGUI currentHealth;

	[SerializeField]
	private TextMeshProUGUI maxHealth;

	[SerializeField]
	private Image healthBar;

	public Image selectedIcon;

	public TextMeshProUGUI addhealthText;

	public Animator addhealthAnimator;

	public bool IsPlayers;

	public void SetupPartyMember(ActivePartyMember Member)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		if (Member != null)
		{
			CurrentMember = Member;
			Icon.sprite = Member.PartyMemberDescription.PartyMemberBattleIcon;
			if ((Object)(object)Member.PartyMemberDescription.PartyMemberBattleIcon != (Object)null)
			{
				RectTransform rectTransform = ((Graphic)Icon).rectTransform;
				Rect textureRect = Member.PartyMemberDescription.PartyMemberBattleIcon.textureRect;
				float num = ((Rect)(ref textureRect)).width * 2f;
				textureRect = Member.PartyMemberDescription.PartyMemberBattleIcon.textureRect;
				rectTransform.sizeDelta = new Vector2(num, ((Rect)(ref textureRect)).height * 2f);
			}
			Name.sprite = Member.PartyMemberDescription.PartyMemberBattle_NameIcon;
			if ((Object)(object)Member.PartyMemberDescription.PartyMemberBattle_NameIcon != (Object)null)
			{
				((Graphic)Name).rectTransform.sizeDelta = new Vector2((float)(((Texture)Member.PartyMemberDescription.PartyMemberBattle_NameIcon.texture).width * 2), (float)(((Texture)Member.PartyMemberDescription.PartyMemberBattle_NameIcon.texture).height * 2));
			}
			if (IsPlayers)
			{
				((TMP_Text)currentHealth).text = PlayerManager.Instance._PlayerHealth.ToString();
				((TMP_Text)maxHealth).text = PlayerManager.Instance._PlayerMaxHealth.ToString();
			}
			else
			{
				((TMP_Text)currentHealth).text = Member.CurrentHealth.ToString();
				((TMP_Text)maxHealth).text = Member.PartyMemberDescription.MaximumHealth.ToString();
			}
			((Graphic)healthBar).color = Member.PartyMemberDescription.PartyMemberColor;
			healthBar.fillAmount = (float)Member.CurrentHealth / (float)Member.PartyMemberDescription.MaximumHealth;
		}
		else
		{
			Debug.LogError((object)"Party member null?");
		}
	}

	public void UpdateHealth(ActivePartyMember Member)
	{
		if (Member != null)
		{
			if (IsPlayers)
			{
				((TMP_Text)currentHealth).text = PlayerManager.Instance._PlayerHealth.ToString();
				((TMP_Text)maxHealth).text = PlayerManager.Instance._PlayerMaxHealth.ToString();
				Member.CurrentHealth = (int)PlayerManager.Instance._PlayerHealth;
			}
			else
			{
				((TMP_Text)currentHealth).text = Member.CurrentHealth.ToString();
				((TMP_Text)maxHealth).text = Member.PartyMemberDescription.MaximumHealth.ToString();
			}
			healthBar.fillAmount = (float)Member.CurrentHealth / (float)Member.PartyMemberDescription.MaximumHealth;
		}
		else
		{
			Debug.LogError((object)"Party member null?");
		}
	}
}
